#include<bits/stdc++.h>
using namespace std;

int t,n,m,l,V;
int d[100002],v[100002],a[100002];
int p[100002],der[1000002];
int unk[100002];
int os,ul;


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	
	cin>>t;
	for(;t;t--){
		memset(unk,0,sizeof(unk));
		memset(der,0,sizeof(der));
		os=0;
		cin>>n>>m>>l>>V;
		ul=m;
		for(int i=1;i<=n;i++)cin>>d[i]>>v[i]>>a[i];
		for(int i=1;i<=m;i++){
			cin>>p[i];
			der[p[i]]=i;
		}
		
		for(int i=1;i<=n;i++){
			if(a[i]<=0&&v[i]<=V)continue;
			else if(a[i]>0){
				int s=0,ded=0;
				for(int j=d[i];j<=l;j++){
					double sp2=v[i]*v[i]+2*a[i]*s;
					s++;
					if(V*V<sp2){
						for(;j<=l;j++){
							if(der[j]!=0){
								unk[der[j]]=max(unk[der[j]],d[i]);
								if(ded==0){
									os++;
									ded=1;
								}
							}
						}
						break;
					}
				}
			}else if(a[i]<0){
				int s=0,ded=0;
				for(int j=d[i];j<=l;j++){
					double sp2=v[i]*v[i]+2*a[i]*s;
					s++;
					if(V*V<sp2){
						if(der[j]!=0){
							unk[der[j]]=max(unk[der[j]],d[i]);
							if(ded==0){
								os++;
								ded=1;
							}
						}
					}else break;
				}
			}else if(a[i]==0){
				for(int j=d[i];j<=l;j++){
					if(der[j]!=0){
						unk[der[j]]=max(unk[der[j]],d[i]);
						os++;
					}
				}
			}
		}
		
		
		for(int i=l;i>=1;i--){
			if(der[i]){
				ul--;
				i=unk[der[i]]+1;
			}
		}
		
		
		
		cout<<os<<' '<<ul<<'\n';
	}
	
	return 0;
}
